package com.baitiaojun.system.admin.controller.permission;

import com.baitiaojun.common.domain.model.result.CommonResult;
import com.baitiaojun.ratelimit.core.annotation.RateLimit;
import com.baitiaojun.system.admin.service.permission.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;

@Slf4j
@RestController
@RequestMapping("/admin/permission")
@Api("权限控制器")
public class PermissionController {

    @Autowired
    private MenuService menuService;

    @PermitAll
    @RateLimit(key = "menuTree", count = 1, time = 3)
    @ApiOperation("查询菜单树")
    @GetMapping("/menuTree")
    public CommonResult queryMenus(@RequestParam Long[] roleIds) {
        return CommonResult.ok(menuService.queryMenuTreeByRoleIds(roleIds));
    }
}
